#pragma once

#include "Profile.h"

#include "ElementImport.h"
#include "PackageImport.h"

namespace uml {

Profile::Profile(const QString& umlType)
    : Package(umlType) {}

void Profile::fromJson(const QJsonObject& json, QStringList& errorList) {
    if (json.isEmpty()) {
        return;
    }

    Package::fromJson(json, errorList);
    JsonSerializable::fromJsonArray(metaclassReferences_, "metaclassReferences", json, errorList);
    JsonSerializable::fromJsonArray(metamodelReferences_, "metamodelReferences", json, errorList);
}

void Profile::toJson(QJsonObject& json) {
    Package::toJson(json);
    JsonSerializable::toJsonArray(metaclassReferences_, "metaclassReferences", json);
    JsonSerializable::toJsonArray(metamodelReferences_, "metamodelReferences", json);
}

/// <summary>
/// metaclassReferences getter
/// References a metaclass that may be extended.
/// </summary>
vector<shared_ptr<ElementImport>>& Profile::metaclassReferences() {
    return metaclassReferences_;
}

/// <summary>
/// metamodelReferences getter
/// References a package containing (directly or indirectly) metaclasses that may be
/// extended.
/// </summary>
vector<shared_ptr<PackageImport>>& Profile::metamodelReferences() {
    return metamodelReferences_;
}

} // namespace uml
